import Vue from 'vue'
import Vuex from 'vuex'
import router from '../router'
import persistedState from 'vuex-persistedstate'
Vue.use(Vuex)


export default new Vuex.Store({
	state: {
		isPc : true,//是否为PC
		coin : null,//币种
		currency : null,
		footer : null,//网页底部内容数据
		logo : null,//logo图片
		nation : null,//国家数据
		payment : null,//支付方式
		userInfo : {
			authorization : null,
			avatar :null,//头像
			nickname : null,//昵称
			user_id : null,//用户id
		},//用户信息
	},
	mutations: {
		changePlatfrom (state, params) {
			state.isPc = params
		},
		setSettings (state, params) {
			state.currency = params.currency;
			state.footer = params.footer;
			state.logo = params.logo;
			state.nation = params.nation;
			state.payment = params.payment;
			state.coin = params.coin;
		},
		//设置用户信息
		setUserInfo (state, params) {
			for (let key in params) {
				state.userInfo[key] = params[key]
			}
			
		},
		//清除用户信息
		clearUserInfo (state) {
			state.userInfo = {
				authorization : null,
				avatar :null,//头像
				nickname : null,//昵称
				user_id : null,//用户id
			}
		},
		//修改用户信息
		updateUserInfo (state, params) {
			state.userInfo[params.key] = params.value
		}
	},
	actions: {
		
	},
	getters : {
		
	},
	modules: {
		
	},
	plugins : [persistedState()]
})